<?php


namespace App\Http\Controllers\cms;


use App\Engine\BaseController;
use function app\Utils\go;
use App\Models\Sys as SysModel;

class Sys extends BaseController
{
    public function get()
    {
        $res=SysModel::get();
        $arr=array();
        $flas=[false,true];
        foreach ($res as $key=>$v){
            if($v['switch']==2){
                $v['value']=(int)$v['value'];
            }
            if($v['switch']==1){
                $v['value']=$flas[$v['value']||0];
            }

            $arr[$v['type']][]=$v;
        }
        return go($arr);
    }

    /**更新系统配置
     * @return array
     * @throws \App\Exceptions\ApiException
     */
    public function update()
    {
        $res=SysModel::update_data($this->post);
        return go($res);
    }
}
